//
//  TabbarViewController.swift
//  Swift_MyLive
//
//  Created by admin on 16/9/7.
//  Copyright © 2016年 admin. All rights reserved.
//

import UIKit



class TabbarViewController: ESTabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
//        let viewVc = ViewController()
//        
//        viewVc.title = "📰新闻"
//        viewVc.tabBarItem.image = UIImage(named: "btn_hospital_choose")
//        
//        let nc = UINavigationController(rootViewController: viewVc)
//        nc.navigationBar.shadowImage = UIImage()
//        self.addChildViewController(nc)
//        
//        let zongYiVc = ZongYiVViewController()
//        
//        zongYiVc.title = "🎢综艺"
//        zongYiVc.tabBarItem.image = UIImage(named: "btn_home")
        
//        let znc = UINavigationController(rootViewController: zongYiVc)
//        znc.navigationBar.shadowImage = UIImage()
//        self.addChildViewController(znc)
        

        self.title = "自定义tabBar"
        self.tabBar.shadowImage = UIImage(named:"transparent")
        self.tabBar.backgroundImage = UIImage(named: "background_dark")
        self.shouldHijackHandler = {
            tabBarController,TabbarViewController,index in
            if index == 2
            {
                return true
            }
            return false
        }
        self.didHijackHandler = {
            
            tabBarController,TabbarViewController, index in
                
//            DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
//                let alertController = UIAlertController.init(title: nil, message: nil, preferredStyle: .actionSheet)
//                let takePhotoAction = UIAlertAction(title: "Take a photo", style: .default, handler: nil)
//                alertController.addAction(takePhotoAction)
//                let selectFromAlbumAction = UIAlertAction(title: "Select from album", style: .default, handler: nil)
//                alertController.addAction(selectFromAlbumAction)
//                let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
//                alertController.addAction(cancelAction)
//                self.present(alertController, animated: true, completion: nil)
//            }
            
        }
        
        
        let news = ViewController()
        let zongYiVc = ZongYiVViewController()
        let my = LivesViewController()
        
//        viewVc.tabBarItem = ESTabBarItem.init(ExampleTipsContentView(),title: "新闻", image: UIImage(named: "photo_verybig"),  selectedImage: UIImage(named: "photo_verybig"), tag: 0)
        
        zongYiVc.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "综艺", image: UIImage(named: "favor"), selectedImage: UIImage(named: "favor_1"), tag: 0)
        
        news.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(),title: "新闻", image: UIImage(named: "home"),  selectedImage: UIImage(named: "home_1"), tag: 1)
        
//        zongYiVc1.tabBarItem = ESTabBarItem.init(ExampleLottieAnimateContentView(), title: "", image: UIImage(named: ""), selectedImage: UIImage(named: "favor_1"), tag: 1)
        
        my.tabBarItem = ESTabBarItem.init(ExampleIrregularityContentView(),title: "我的", image: UIImage(named: "photo_verybig"),  selectedImage: UIImage(named: "photo_verybig"), tag: 0)
        
         let newsVcn = UINavigationController.init(rootViewController: news)
         let zongYiVcn = UINavigationController.init(rootViewController: zongYiVc)
        let myNcn = UINavigationController.init(rootViewController: my)

        self.addChildViewController(newsVcn)
        self.addChildViewController(zongYiVcn)
        self.addChildViewController(myNcn)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
